package com.tablefood.dao.Impl;

import java.util.List;

import javax.annotation.Resource;
  
import org.hibernate.Query;
import org.hibernate.SessionFactory;

import com.tablefood.dao.AdminDao;
import com.tablefood.domain.ShopAdmin;
 

public class AdminDaoImpl implements AdminDao {

	@Resource
	private SessionFactory sessionFactory; 
	
	@Override
	public boolean loginAdmin(ShopAdmin admin) {
		
		String hql = "FROM ShopAdmin AS u WHERE u.adminuser = ? AND u.adminpass = ?"; 
		 
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setString(0, admin.getAdminuser());  
		query.setString(1, admin.getAdminpass());
		
		@SuppressWarnings("unchecked")
		List<ShopAdmin> result = query.list();  
	 

		if (result != null && result.size() > 0) {
			//System.out.println("用户登录成功");
			return true;
		}else{
			//System.out.println("用户名或密码错误");
			return false;
		}
		
	}

}
